home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / Scissors.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  101 lines

  1. /**********************************************************************\
  2.  
  3. File:        Scissors.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 3
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short Scissors(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* A region in two parts, starting at the top of the left and right sides and
  34.    moving down the sides and together towards the middle of the bottom side. */
  35.    
  36. pascal short Scissors(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  37. {
  38.     RgnHandle    curregion;
  39.     int            cx,gap,lastx,lasty;
  40.     int            BlockSize;
  41.     
  42.     BlockSize=theWindowHeight/25;
  43.     cx = theWindowWidth / 2;
  44.  
  45.     curregion=NewRgn();
  46.     gap=BlockSize;
  47.     lasty=0;
  48.     do
  49.     {
  50.         StartTiming();
  51.         SetEmptyRgn(curregion);
  52.         MoveTo(cx,0);
  53.         OpenRgn();
  54.             LineTo(theWindowWidth,lasty);   /* get the right half */
  55.             LineTo(theWindowWidth,gap);
  56.             LineTo(cx,0);
  57.             LineTo(0,lasty);                   /* get the left half */
  58.             LineTo(0,gap);
  59.             LineTo(cx,0);
  60.         CloseRgn(curregion);
  61.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  62.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  63.             &boundsRect, &boundsRect, 0, curregion);
  64.         lasty=gap;
  65.         gap+=BlockSize;
  66.         TimeCorrection(CorrectTime);
  67.     }
  68.     while (gap<theWindowHeight+BlockSize);
  69.     
  70.     lastx=theWindowWidth;
  71.     gap=theWindowWidth-BlockSize;
  72.     do
  73.     {
  74.         StartTiming();
  75.         SetEmptyRgn(curregion);
  76.         MoveTo(cx,0);
  77.         OpenRgn();
  78.             LineTo(lastx,theWindowHeight);        /* get the right half on bottom side */
  79.             LineTo(gap,theWindowHeight);
  80.             LineTo(cx,0);
  81.             LineTo(theWindowWidth-lastx,theWindowHeight);    /* left 1/2 on bottom */
  82.             LineTo(theWindowWidth-gap,theWindowHeight);
  83.             LineTo(cx,0);
  84.         CloseRgn(curregion);
  85.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  86.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  87.             &boundsRect, &boundsRect, 0, curregion);
  88.         lastx=gap;
  89.         gap-=BlockSize;
  90.         TimeCorrection(CorrectTime);
  91.     }
  92.     while (gap>theWindowWidth/2);
  93.     
  94.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  95.         &boundsRect, &boundsRect, 0, 0L);        /* if we missed any bits */
  96.     
  97.     DisposeRgn(curregion);
  98.     
  99.     return 0;
  100. }
  101.